#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright [Gtlions Lai].
# Create Date:
# Update Date:
"""summarization ahout this script.

detail ahout this script

   Class(): summarization about Class
   ...
   function(): summarization about function
   ...
"""
__authors__ = '"Gtlions Lai" <gtlions.l@qq.com>'

import sys
from PyQt4 import QtGui, QtCore
import fdb


class Main(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle('Radio Button')
        self.setGeometry(300, 300, 300, 300)
        grid = QtGui.QGridLayout()
        self.setLayout(grid)

        conn = fdb.connect(dsn="../gtdb/gtlions1.fdb", user="gtlions", password="G1!tlion", charset="utf8")
        cur = conn.cursor()
        cur.execute("select * from std")
        ret = cur.fetchall()
        row = len(ret)
        if row:
            col = len(ret[0])
        else:
            row = 0
            col = 0

        self.qt1 = QtGui.QTableWidget()
        grid.addWidget(self.qt1)
        self.qt1.setRowCount(row)
        self.qt1.setColumnCount(col)
        self.qt1.setHorizontalHeaderLabels([u'编号',u'姓名',u'年龄'])

        for x in range(row):
            for y in range(col):
                item = ret[x][y]
                #print isinstance(item, unicode)
                if isinstance(item, unicode):
                    pass
                else:
                    item = str(item)
                self.qt1.setItem(x, y, QtGui.QTableWidgetItem(item))

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    main = Main()
    main.show()
    sys.exit(app.exec_())